﻿using Code;
using github.heerheer.card2.UI.Infos;
using HeerCards.Helper;
using Panuon.UI.Silver;
using System.Windows;

namespace github.heerheer.card2.UI.Views
{
    /// <summary>
    /// ProCheckView.xaml 的交互逻辑
    /// </summary>
    public partial class ProCheckView : Window
    {
        ProCodeSaver ps = new ProCodeSaver();
        public ProCheckView()
        {
            InitializeComponent();
            ps.Dir = AppMain.Common.AppDirectory;

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var info = VIPHelper.checkVIP(Menu_Open.fromQQ.ToString(), CodeText.Text.Trim());
            if (info.isVIP)
            {
                AppMain.VipInfo = info;
                MessageBoxX.Show("激活成功！\n请重启酷q", "激活");
                ps.saveCode(CodeText.Text.Trim());
                this.DialogResult = true;

            }
            else
            {
                info = VIPHelper.checkVIP( CodeText.Text.Trim());
                if (info.QQ == "")
                {
                    //绑定
                    var r = VIPHelper.bindVIPQQ(CodeText.Text.Trim(), AppMain.Common.GetLoginQQId().ToString());
                    this.DialogResult = r;
                }
                else
                {
                    AppMain.VipInfo = info;
                    MessageBoxX.Show("激活失败：激活码已被使用/不存在的激活码", "激活");
                    this.DialogResult = false;
                }

            }
        }

        private void Button_Click2(object sender, RoutedEventArgs e)
        {
            
            this.DialogResult = false;
        }
    }
}